<?php

/**
 * UserRoles storage class
 *
 * @author    Mon Zafra <monzee at gmail>
 * @copyright (c)2009 Mon Zafra
 * @license   http://monzee.wordpress.com/license New BSD
 * @version   $Id: UserRoles.php 38 2009-02-18 17:12:39Z monzee $
 */
class Admin_Array_UserRoles
{
    protected $_userRoles = array();

    public function __construct()
    {
        $this->_userRoles = array(
            array(
                'user_id' => 1, // admin
                'role_id' => 'admin', // Administrator
            ),
            array(
                'user_id' => 2, // monzee
                'role_id' => 'author', // Author
            ),
            array(
                'user_id' => 3, // anon
                'role_id' => 'member', // Member
            ),
            array(
                'user_id' => 4, // foo
                'role_id' => 'mod', // Moderator
            ),
            array(
                'user_id' => 5, // superman
                'role_id' => 'editor', // Editor
            ),
            array(
                'user_id' => 6, // john
                'role_id' => 'author', // Author
            ),
            array(
                'user_id' => 6, // john
                'role_id' => 'mod', // Moderator
            ),
            array(
                'user_id' => 7, // superadmin
                'role_id' => 'admin', // Administrator
            ),
            array(
                'user_id' => 7, // superadmin
                'role_id' => 'author', // Author
            ),
            array(
                'user_id' => 7, // superadmin
                'role_id' => 'mod', // Moderator
            )
        );
    }

    /**
     * Returns all the roles of a user
     *
     * @param int $userId
     * @return array containing role ids
     */
    public function getRolesByUserId($userId)
    {
        $userRoles = $this->_userRoles;
        $roles = array();
        foreach ($userRoles as $userRole) {
            if ($userRole['user_id'] == $userId) {
                $roles[] = $userRole['role_id'];
            }
        }
        
        return $roles;
    }

}
